Skip to content

Change from aiohttp to httpx #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 18, 2025
Merged

Change from aiohttp to httpx #598

merged 6 commits into from
Jun 18, 2025

Conversation

ponyisi
Copy link
Collaborator

@ponyisi ponyisi commented May 22, 2025

We were using both aiohttp and httpx for connections to the backend. Standardize on httpx (which has, currently, better free-thread support).

@ponyisi ponyisi requested a review from Copilot May 22, 2025 20:58
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.54%. Comparing base (2e24a67) to head (bf50461).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #598      +/-   ##
==========================================
+ Coverage   96.20%   96.54%   +0.33%     
==========================================
  Files          29       29              
  Lines        1870     1995     +125     
==========================================
+ Hits         1799     1926     +127     
+ Misses         71       69       -2     
Flag Coverage Δ
unittests 96.54% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Standardize on httpx by replacing aiohttp-based clients and retries with httpx.AsyncClient and httpx_retries.

  • Swap out aiohttp.ClientSession/RetryClient for httpx.AsyncClient with RetryTransport
  • Update all response checks to use status_code and JSON decoding to use JSONDecodeError
  • Adjust tests to mock httpx client methods and remove context‐manager mocks

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_servicex_adapter.py Mocked ClientSession.get/post/delete, switched to JSONDecodeError
servicex/servicex_adapter.py Replaced aiohttp imports and retries with httpx client and retry transport
pyproject.toml Removed aiohttp-retry dependency, added httpx_retries
Comments suppressed due to low confidence (1)

servicex/servicex_adapter.py:53

  • httpx.Response.json() is synchronous, so await r.json() will error; call r.json() directly (and similarly remove await for other .json() calls).
o = await r.json()

Copy link
Contributor

@BenGalewsky BenGalewsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great contribution! Thank you.- just a request to follow Copilot's suggestion, but otherwise wonderful

@ponyisi ponyisi requested a review from BenGalewsky June 6, 2025 16:50
Copy link
Contributor

@BenGalewsky BenGalewsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

@ponyisi ponyisi merged commit 8f95a15 into master Jun 18, 2025
37 checks passed
@ponyisi ponyisi deleted the aiohttp-to-httpx branch June 18, 2025 20:49
@matthewfeickert
Copy link
Member

Coming here from conda-forge/servicex-feedstock#11: If you're all happy with httpx-retires that's great, but one of the conda-forge core maintainers recommended Hynek's stamina as an alternative: https://github.com/hynek/stamina

I have no knowledge of the use case here or other package, other than any tool maintained by Hyenk is of exceptional quality and stability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants